package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.Warehouse;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface WarehouseMapper extends Mapper<Warehouse> {
    @Select("select * from t_cl_warehouse where warehouse_id = #{warehouseId} ")
    Warehouse selectWarehouseById(@Param("warehouseId") Integer warehouseId);
    @Select("select * from t_cl_warehouse   ")
    List<Warehouse> getWarehouse();
    @Update("update t_cl_warehouse set warehouse_status = 0 where warehouse_id = #{warehouseId}")
    void updateWarehouseDownById(@Param("warehouseId") Integer warehouseId);

    @Update("update t_cl_warehouse set warehouse_status = 1 where warehouse_id = #{warehouseId}")
    void updateWarehouseUp(@Param("warehouseId") Integer warehouseId);
    @Select("select w.warehouse_id,w.warehouse_name,w.warehouse_status,w.company_id,c.company_name from t_cl_warehouse w INNER JOIN t_cl_company c ON w.company_id=c.company_id  where w.warehouse_name like '%${warehouseName}%' ")
    List<Warehouse> getWarehouseByName(@Param("warehouseName") String warehouseName);
    @Insert("insert into t_cl_warehouse (warehouse_name,warehouse_status,company_id) values (#{warehouseName},1,#{companyId}) ")
    void addSelective(Warehouse warehouse);
}
